﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lm.Common.DAL;

namespace Lm.Common.Auth.Examples
{
    class Account
    {
        public void AddDraft()
        {
            new Lm.Common.Auth.Account.AccountDraftEditor("8522dd1302274775a2f5b31141afa24a")
            .Add(new Model.Account()
            {
                Name = "刘明",
                Password = "123",
                Pause = false,
                Remark = "备注",
                UserAccount = "liuming",
            }, "user");
        }

        public void DeleteDraft()
        {
            new Lm.Common.Auth.Account.AccountDraftEditor("8522dd1302274775a2f5b31141afa24a")
            .RemoveAccount("liuming");
        }

        internal void Modify()
        {
            new Lm.Common.Auth.Account.AccountDraftEditor("8522dd1302274775a2f5b31141afa24a")
           .Modify(new Model.Account()
           {
               Name = "刘明2",
               Password = "admin",
               Pause = true,
               Remark = "1",
               UserAccount = "liuming",
           }, "admin");
        }

        internal void Confirm()
        {
            new Lm.Common.Auth.Account.AccountAdmin("8522dd1302274775a2f5b31141afa24a")
            .ConfirmAccount("liuming");
        }

        internal void KillAccount()
        {
            new Lm.Common.Auth.Account.AccountAdmin("8522dd1302274775a2f5b31141afa24a")
            .KillAccount("liuming");
        }

        internal void ModifyLive()
        {
            new Lm.Common.Auth.Account.AccountAdmin("8522dd1302274775a2f5b31141afa24a")
           .Modify(new Model.Account()
           {
               Name = "刘明2",
               Password = "admin",
               Pause = false,
               Remark = "备注",
               UserAccount = "admin",
           }, "admin");
        }

        internal void Select()
        {
            var list = new Lm.Common.Auth.Account.AccountSelector("8522dd1302274775a2f5b31141afa24a")
              .GetAccountList(t => t.UserAccount.EndWithSqlLike("g"));

            long count;
            var list2 = new Lm.Common.Auth.Account.AccountSelector("8522dd1302274775a2f5b31141afa24a")
            .GetAccountList(1, 2, out count, t => t.Name == "");
        }

        public void ChangePassword()
        {
            new Lm.Common.Auth.Account.ChangePassword("8522dd1302274775a2f5b31141afa24a")
            .Change("admin2", "admin", "admin");
        }
    }
}
